package com.platform.enums;

import com.platform.comm.constants.EnumOption;
import com.platform.comm.enums.IDictEntry;
import com.platform.comm.enums.IEnumItem;
import com.platform.comm.enums.IEnumOption;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 数据模型-导入新增-导入记录使用
 * @author zq
 */

@EnumOption(name = "metaBatchJobStatus")
public enum MetaBatchJobStatus implements IDictEntry, IEnumItem, IEnumOption<String> {
    /*
     */
    STARTED("STARTED", "运行中"),
    COMPLETED("COMPLETED", "成功"),
    FAILED("FAILED", "失败"),
    ;

    public final String code;
    public final String title;


    MetaBatchJobStatus(String code, String title) {
        this.code = code;
        this.title = title;
    }

    @Override
    public boolean is(String code) {
        return this.code.equals(code);
    }

    @Override
    public String getKey() {
        return code;
    }

    @Override
    public String getValue() {
        return title;
    }

    @Override
    public Object getData() {
        return this;
    }


    /**
     * 枚举项 “键”
     *
     * @return key
     */
    @Override
    public String key() {
        return code;
    }

    /**
     * 枚举项 “值”
     *
     * @return value
     */
    @Override
    public String value() {
        return title;
    }

    /**
     * 枚举options
     *
     * @return
     */
    @Override
    public Map<String, String> enums() {
        return Arrays.stream(values()).collect(Collectors.toMap(IEnumOption::key, IEnumOption::value));
    }
}
